#ifndef ENITY_H
#define ENITY_H

#include <d3dx9.h>
#include <d3d9.h>
#include <limits>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <time.h>

#include "EDirect.h"
#include "Sprite.h"
#include "Camera.h"
#include "Input.h"



class CEntity
{

private:
	RECT getSweptBroadphaseBox(CEntity*);
	float getWCollision();
	float getHCollision();
	float getPosXCollision();
	float getPosYCollision();

public:

	float m_posX;
	float m_posY;
	float m_posX_old;
	float m_posY_old;
	float m_vecX;
	float m_vecY;
	float m_accX;
	float m_accY;

	int m_width;
	int m_heigth;
	
	RECT m_rect;
	
	DirectCollision m_collsion; // trang thai bi va cham hien tai

	// tra ve va cham doi voi vat di chuyen cua vat this	
	DirectCollision AABBCollision( CEntity* b, float& colTime);
	bool Collision(RECT a, RECT b);

	float m_LeftDeviation;
	float m_RightDeviation;
	float m_TopDeviation;
	float m_BotDeviation;
	
	CEntity();
	CEntity(float posX, float posY, int width, int height);
	~CEntity();

	void setPostion(D3DXVECTOR2 x);
	void setPostion(float posX, float posY);

	float getPosX(){ return m_posX; }
	void setPosX(float x){ m_posX = x; }
	float getPosXOld(){ return m_posX_old; }
	void setPosXOld(float x){ m_posX_old = x; }
	float getPosY(){ return m_posY; }	
	void setPosY(float x){ m_posY = x; }
	float getPosYOld(){ return m_posY_old; }
	void setPosYOld(float x){ m_posY_old = x; }
	float getVecX(){ return m_vecX; }
	void setVecX(float x){ m_vecX = x; }
	float getVecY(){ return m_vecY; }
	void setVecY(float x){ m_vecY = x; }
	float getAccX(){ return m_accX; }
	void setAccX(float x){ m_accX = x; }
	float getAccY(){ return m_accY; }
	void setAccY(float x){ m_accY = x; }
	float getHeight(){ return m_heigth; }
	float getWidth(){ return m_width; }
	void setWidth(int x){ m_width = x; }
	void setHeight(int x){ m_heigth = x; }
	RECT getRect();
	void setRect(RECT rect) { m_rect = rect; }

	void setLeftDeviation(float leftDeviation);
	void setRightDeviation(float rightDeviation);
	void setTopDeviation(float topDeviation);
	void setBotDeviation(float botDeviation);
	void setDeviation(float leftDeviation, float rightDeviation, float topDeviation, float botDeviation);
	void setNoneDeviation();

	void moveEnity();
	void moveEnity(float vecX, float vecY);

	void updateVec(float time);
	void stopPhysic();
	void stopVec();
	void setPhysic(float vecX,float vecY,float accX,float accY);

};




#endif